from django.contrib import admin
from .models import Category,Product
# Register your models here.
@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    list_display = ['name','slug']
    #prepopulated_fields用于让slug字段通过name字段自动生成
    prepopulated_fields = {'slug':('name',)}

@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
    list_display = ['name','slug','price','available','created','updated']
    list_filter = ['available','created','updated']
    #可以一次性编辑多行而不用点开每一个对象
    list_editable = ['price','available']
    prepopulated_fields = {'slug':('name',)}



